const gulp = require('gulp');
const babel = require("@babel/core");
const through2 = require('through2');
function jsTranser(destPath, jsPaths) {
    console.log('Start compile jsx,js');
    return gulp.src(jsPaths)
        .pipe(
            through2.obj(function (file, encoding, next) {
                let jsContent = babel.transformFileSync(file.path, {
                    presets: ['@babel/preset-env']
                });
                file.contents = Buffer.from(jsContent.code);
                this.push(file);
                next();
            })
        )
        .pipe(gulp.dest(destPath))
        .on('end', function () {
            console.log('Done compile jsx,js');
        })
}
module.exports = jsTranser;